// src/features/members/api/use-get-members.ts
import {MARK_DATA_URL} from "@/lib/social/constants";

export const useGetMembers = async ({workspaceId}: { workspaceId: string }) => {
    // todo: get current user

    // 获取指定工作区的所有用户
    const res = await fetch(
        // `${MARK_DATA_URL}/members?workspaceId=${workspaceId}`,
        `/api/members?workspaceId=${workspaceId}`,
    )
    let members = await res.json()
    console.log('use get members', members)
    // members = members.members

    let isLoading = true
    // let data = []
    // 获取所有用户的user信息
    // for (const member of members) {
    //     // const uRes = await fetch(`${MARK_DATA_URL}/users/${member.userId}`)
    //     const uRes = await fetch(`/api/users/${member.userId}`)
    //     const uData = await uRes.json()
    //     data.push({
    //         ...member,
    //         user: uData
    //     })
    // }
    isLoading = false


    return {data: members, isLoading}
}